<?php

include_once 'dbTools.php';

$uesrname = $_POST['uesrname'];
$password = $_POST['password'];

$userid = getUserIdByUserNameAndPwd($uesrname,$password);

$userKey = md5($uesrname.$password);

//设置COOKIES=>给客户端
setcookie('userKey',$userKey,time()+24*3600,'/');
//把$userid值保留在服务器内存
//1. 开启session功能

session_start();
//2. 设置session
$_SESSION[$userKey] = [
    'userid'=>$userid,
    'uesrname'=>$uesrname
];

print_r($_SESSION);


echo '登入成功！';
echo '<br /><a href="user.php">用户中</a>';

